<template>
  <div>
    <button @click="login">登陆</button>
  </div>
</template>
<script>
import { mapMutations } from 'vuex'
export default {
  data() {
    return {}
  },
  methods: {
    login() {
      this.setToken('12345')
      this.$router.push('/dashboard')
    },
    ...mapMutations({
      setToken: 'SET_TOKEN' // 将 `this.add()` 映射为 `this.$store.commit('increment')`
    })
  }
}
</script>
